//$(function(){
	//initSelect();
	/* 将密码区域进行转换
	 * $( '#passwordShow' ).hide();
	$( '#passwordShow').blur( function(){
		$('#passwordShow').hide();
		$('#password').show();
	});
	
	$( '#password').focus( function(){
		$('#password').hide();
		$('#passwordShow').show();
		$('#passwordShow').focus();
	});*/
	
	
	
	/*$('#clazz').blur(function(){
		check_clazz();
	});*/
	/*$('#data_form_content').submit(function(event){
		return emailFlag&&check_age()&&check_sex()&&check_phone&&check_email()&&check_clazz()&&check_academic()&&check_graduated()&&check_schoolName();
	})*/
//})

function ajaxCheckMail(){
    var flag = false;
	var email=$('#email').val();
	 if(email==""){
		    $('#emailInfo').html("邮箱不能为空");
	 		return false;
	 }
	 var reg=/\b(^['_A-Za-z0-9-]+(\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/;
	 if(!reg.test(email)){
		    $("#emailInfo").html("邮箱格式错误");
			return false;
	 }
	 var id = $('#userId').val();
	 $.ajax({				
		'url':'userAction!checkMail',
		'type':'post',
		'data':'userId='+id+'&user.email='+email,
		'success':function( data ){
			if( data == "ok" ){
				flag = true;
				$('#emailInfo').html( "可以使用" );
			}else{
				flag = false;
				$( '#emailInfo' ).html( "邮箱已经被注册" );
			}
		},
		'async':false
	});
	return flag;
}

function initSelect(){
	var sex = $( '#sexValue' ).val();
	
	$( "#sex option[value='" + sex +"']" ).attr( 'selected', 'true' );
	
	var clazz = $('#clazzValue' ).val();
	if( clazz.length > 1 ){
		$( "#clazz option[value='" + clazz + "']").attr( 'selected', 'true' );
	}
	
	var academic = $('#academicValue' ).val();
	$( "#academic option[value='" + academic + "']").attr( 'selected', 'true' );
	
	var graduated = $('#graduatedValue' ).val();
	$( "#graduated option[value='" + graduated + "']").attr( 'selected', 'true' );
}


function check_phone(){
	$('#phoneInfo').html("");
	var pwd=$('#phone').val();
	if(pwd==""){
		$('#phoneInfo').html("手机不能为空");
		return false;
	}
	var teg=/^((13[0-9])|(15[0-9])|(18[0-9]))[0-9]{8}$/;
	if(!teg.test(pwd)){
		$('#phoneInfo').html("手机格式错误");
		return false;
	}
	$('#phoneInfo').html("手机格式正确");
	return true;
}

function check_email(){
	$('#emailInfo').html("");
	var email=$('#email').val();
	 if(email==""){
	 		$('#emailInfo').html("邮箱不能为空");
	 		return false;
	 }
	 
	 var reg=/\b(^['_A-Za-z0-9-]+(\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/;
	 if(!reg.test(email)){
			$("#emailInfo").html("邮箱格式错误");
			return false;
		}
	return true;
}

function check_age(){
	$('#ageInfo').html( "" );
	var age = $('#age').val();
	if( age=="" ){
		$('#ageInfo').html("年龄不能为空");
		return false;
	}
	
	var reg = /^(1[6-9])|([2|3][0-9])$/;
	if( !reg.test( age ) ){
		$('#ageInfo').html("请输入正确的年龄");
		return false;
	}
	$('#ageInfo').html("");
	return true;
}

function check_sex(){
	$('#sexInfo').html( "" );
	
	var sex = $('#sex').val();
	
	if( sex=="" ){
		$('#sexInfo').html("年龄不能为空");
		return false;
	}
	
	$('#sexInfo').html("");
	return true;
}

function check_clazz(){
	$('#clazzInfo').html( "" );
	var clazz= $('#clazz').val();
	if( clazz=="" ){
		$('#clazzInfo').html("班级不能为空");
		return false;
	}
	$('#clazzInfo').html( "" );
	return true;
}

function check_graduated(){
	$('#graduatedInfo').html( "" );
	var clazz= $('#graduated').val();
	if( clazz=="" ){
		$('#graduatedInfo').html("班级不能为空");
		return false;
	}
	$('#graduatedInfo').html( "" );
	return true;
}

function check_school(){
	$('#schoolInfo').html("");
	var name=$('#school').val();
	var teg=/^[\u4e00-\u9faf]{4,15}$/;
	if(name==""){
		$('#schoolInfo').html("学校名不能为空");
		return false;
	}
	
	if(!teg.test(name)){
		$('#schoolInfo').html("学校名格式不对");
		return false;
	}
	return true;
}

function check_nickname(){
	$('#nicknameInfo').html("");
	var name=$('#nickname').val();
	var teg=/^[\u4e00-\u9faf]{2,15}$/;
	if(name==""){
		$('#nicknameInfo' ).html("昵称不能为空");
		//alert( "nickname" );
		return false;
	}
	
	if(!teg.test(name)){
		$('#nicknameInfo').html("昵称格式不对");
		return false;
	}
	return true;
}

function check_name(){
	$('#nameInfo').html("");
	var name=$('#name').val();
	var teg=/^[\u4e00-\u9faf]{2,3}$/;
	if(name==""){
		$('#nameInfo').html("姓名不能为空");
		return false;
	}
	
	if(!teg.test(name)){
		$('#nameInfo').html("姓名格式不对");
		return false;
	}
	return true;
}

function check_QQ(){
	$('#QQInfo').html( "" );
	var clazz= $('#QQ').val();
	var teg=/^(?!0{1})\d{6,10}$/;
	if( clazz=="" ){
		$('#QQInfo').html("QQ号不能为空");
		return false;
	}
	
	if(!teg.test(clazz)){
		$('#QQInfo').html("QQ格式不对");
		return false;
	}
	
	$('#QQInfo').html( "" );
	return true;
}


function check_academy(){
	$('#academyInfo').html( "" );
	var clazz= $('#academy').val();
	var teg=/^[\u4e00-\u9faf]{4,15}$/;
	if( clazz=="" ){
		$('#academyInfo').html("学院名不能为空");
		return false;
	}
	
	if(!teg.test(clazz)){
		$('#academyInfo').html("学院名格式不对");
		return false;
	}
	
	$('#academyInfo').html( "" );
	return true;
}


function check_faculty(){
	$('#facultyInfo').html( "" );
	var clazz= $('#faculty').val();
	var teg=/^[\u4e00-\u9faf]{4,15}$/;
	if( clazz=="" ){
		$('#facultyInfo').html("专业名不能为空");
		return false;
	}
	
	if(!teg.test(clazz)){
		$('#facultyInfo').html("专业名格式不对");
		return false;
	}
	
	$('#facultyInfo').html( "" );
	return true;
}


function check_host(){
	$('#hostInfo').html( "" );
	var ip = $('#host').val();
	if( ip=="" ){
		$('#hostInfo').html("服务器地址不能为空");
		return false;
	}
	var reg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	
	if( !reg.test( ip ) ){
		$('#hostInfo').html("服务器地址不合法");
		return false;
	}
	
	var s = ip.split( '.' );
	var p;
	for( p in s ){
		if( s[p]>255 ){
			$('#hostInfo').html("服务器地址不合法");
			return false;
		}
	}
	
	$('#hostInfo').html( "" );
	return true;
}

function check_ipAddr(){
	$('#ipAddrInfo').html( "" );
	var ip = $('#ipAddr').val();
	if( ip=="" ){
		$('#ipAddrInfo').html("本机地址不能为空");
		return false;
	}
	var reg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	
	if( !reg.test( ip ) ){
		$('#ipAddrInfo').html("本机地址不合法");
		return false;
	}
	
	var s = ip.split( '.' );
	var p;
	for( p in s ){
		if( s[p]>255 ){
			$('#ipAddrInfo').html("服务器地址不合法");
			return false;
		}
	}
	
	$('#ipAddrInfo').html( "" );
	return true;
}